﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;

namespace Week15_LAB01
{
    /// <summary>
    /// Service1 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ToolboxItem(false)]
    // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务，请取消对下行的注释。
        // [System.Web.Script.Services.ScriptService]
    public class Service1 : System.Web.Services.WebService
    {
        [WebMethod]
        public string GenerateNumber()
        {
            int number = 0;

            Random random = new Random();

            number = random.Next(1, 100);
            return number.ToString();
        }

        [WebMethod]
        public string GenerateOperator()
        {
            int number = 0;
            string operatorStr = "";

            Random random = new Random();
            number = random.Next(1, 4);


            switch (number)
            {
                case 1:
                    operatorStr = "+";
                    break;
                case 2:
                    operatorStr = "-";
                    break;
                case 3:
                    operatorStr = "*";
                    break;
                case 4:
                    operatorStr = "/";
                    break;
                default:
                    break;
            }

            return operatorStr;
        }

        [WebMethod]
        public string Add(int x, int y)
        {
            int result = 0;

            result = x + y;

            return result.ToString();
        }

        [WebMethod]
        public string Sub(int x, int y)
        {
            int result = 0;

            result = x - y;

            return result.ToString();
        }

        [WebMethod]
        public string Multiply(int x, int y)
        {
            int result = 0;

            result = x*y;

            return result.ToString();
        }

        [WebMethod]
        public string Divide(int x, int y)
        {
            float result = 0;

            result = x/y;

            return result.ToString();
        }
    }
}